package panel.viewSpots.navigation
{
	import assists.Lang;
	import assists.SizeManager;
	import assists.resource.ResourceLoader;
	
	import flash.display.Sprite;
	import flash.display.Stage;
	import flash.events.MouseEvent;
	
	import panel.viewSpots.MenuDownSlide;
	import panel.viewSpots.navigationNew.NavigationSearchPanel;
	
	public class NavigationMenuDown extends Sprite
	{
		private var _loader:ResourceLoader;
		private var _stage:Stage;
		private var _lang:Lang;
		
//		private var _settingBtn:BtnClouree;
		private var _shareBtn:BtnClouree;
		private var _searchBtn:BtnClouree;
		private var _gongLueBtn:BtnClouree;
		private var _btnList:Array = [];
		private var _onSearch:Function;
		private var _onWeibo:Function;
		private var _slideMenu:MenuDownSlide;
		public function NavigationMenuDown(loader:ResourceLoader,stage:Stage,lang:Lang)
		{
			_loader = loader;
			_stage = stage;
			init();
		}
		
		private function init():void
		{
			this.graphics.beginFill(0x0099ff);
			this.graphics.drawRect(0,0,_stage.stageWidth,_stage.stageHeight * 0.1);
			this.graphics.endFill();
			
//			_settingBtn = new BtnClouree();
//			_settingBtn.label("设置");
			
			_searchBtn = new BtnClouree();
			_searchBtn.label("搜索");
			
			_shareBtn = new BtnClouree();
			_shareBtn.label("分享");
			
			_gongLueBtn = new BtnClouree();
			_gongLueBtn.label("更多");
			
			_gongLueBtn.width = _searchBtn.width =  _shareBtn.width = _stage.stageWidth * 0.25;
			_gongLueBtn.height = _searchBtn.height = _shareBtn.height = _stage.stageHeight * 0.08;
			
			_btnList.push(_searchBtn,_shareBtn,_gongLueBtn);
			
			_slideMenu = new MenuDownSlide(_stage,_loader);
			_slideMenu.visible = false;
			_slideMenu.y = _stage.stageHeight * 0.1;
			
			layout();
			this.addChild(_searchBtn);
			this.addChild(_shareBtn);
//			this.addChild(_settingBtn);
			this.addChild(_gongLueBtn);
			this.addChild(_slideMenu);
			_searchBtn.addEventListener(MouseEvent.CLICK,searchHandler);
			_slideMenu.addEventListener(MouseEvent.CLICK,clickSlideMenu);
//			_settingBtn.addEventListener(MouseEvent.CLICK,settingHandler);
			_shareBtn.addEventListener(MouseEvent.CLICK,shareHandler);
			_gongLueBtn.addEventListener(MouseEvent.CLICK,gongLueHandler);
		}
		
		protected function clickSlideMenu(event:MouseEvent):void
		{
			_slideMenu.backMenu();
		}
		
		private function cancelMoreMenu():void
		{
			_slideMenu.backMenu();
		}
		
		protected function gongLueHandler(event:MouseEvent):void
		{
			trace("more");
			_slideMenu.visible = true;
			_slideMenu.start();
		}
		
		override public function get height():Number
		{
			return _stage.stageHeight * 0.1;
		}
		
		protected function shareHandler(event:MouseEvent):void
		{
			trace("share");
			_onWeibo();
		}
		
		protected function settingHandler(event:MouseEvent):void
		{
			trace("setting");
		}
		
		protected function searchHandler(event:MouseEvent):void
		{
			trace("search");
			_onSearch();
		}
		
		public function onFuncs(searchFunc:Function,weiboFunc:Function,hideArrow:Function,showWc:Function):void
		{
			_onSearch = searchFunc;
			_onWeibo = weiboFunc;
			_slideMenu.show([{desc:"周边洗手间",func:showWc},{desc:"显示/隐藏路线",func:hideArrow},{desc:"取消",func:cancelMoreMenu}]);
		}
		
		private function layout():void
		{
			var btn:BtnClouree;
				for(var i:int=0;i<_btnList.length;i++)
				{
			btn = _btnList[i];
			btn.y = (this.height - btn.height) / 2;
			btn.x = i * btn.width * 1.2 + btn.width * 0.2;
				}
			
		}
		
	}
}